package com.raising.sc.upload.file.server.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;

import javax.servlet.MultipartConfigElement;

/**
 * 上传文件配置
 * @author GaoYuan
 * @date 2018/4/10 上午10:59
 */
@EnableAutoConfiguration
public class UploadConfig {
    //获取配置文件中图片的路径
    @Value("${raising.upload.maxFileSize}")
    private String maxFileSize;
    @Bean
    MultipartConfigElement createMultipartConfigElement() {
        MultipartConfigFactory mcf = new MultipartConfigFactory();
        /** 设置最大上传文件的大小，默认是10MB */
        mcf.setMaxFileSize(maxFileSize);
        return mcf.createMultipartConfig();
    }
}
